<?php

$venderList = Blyn::app()->getActiveApp()->findVenderListByEventType();
$courtTypeList = Blyn::app()->getActiveApp()->getCourtTypeList();
$city = Blyn::app()->getCurrentUser()->getAttribute('myCity_app' . Blyn::app()->getActiveApp()->getId())->getValue();
$app = Blyn::app()->getActiveApp();
$venderCourtTypeBookableList = array();

foreach ($venderList as $id => $vender) {
    $findText1 = 'city=' . $city;
    $venderCount = 0;
    $venderId = $vender->getMediaManager()->getMedia('venderId')->getContent();
    $venderName = $vender->getMediaManager()->getMedia('venderName')->getContent();
    $findText1 .= ' venderId=' . $id;
    $isShowVenderTitile = FALSE;
    foreach ($courtTypeList as $courtType => $courtName) {
        $findText = $findText1 . ' courtType=' . $courtType;
        $count = $app->findCountByFindText($findText, array('itemMatch' => '='));
        if (is_numeric($count) && $count > 0) {
            if (!$isShowVenderTitile) {
                echo '<legend><h4> ' . $venderName . '</h4></legend>';
                $isShowVenderTitile = TRUE;
            }
            $venderCount += $count;
            echo '<div><strong>' . $courtName . '---还有：</strong>' .
            $control->getAjaxLink(array(
                'name' => $count . '个场地',
                'id' => 'showBookingList'), array(
                'findText' => $findText,
                'findContext' => serialize(array('itemMatch' => '=')))
            ) .
            '可以预定</div>';
        }
    }
}
?>